package com.itheima.test;

import java.util.ArrayList;

public class ArrayListDemo03 {
    public static void main(String[] args) {
        //创建学生对象，姓名、年龄

        ArrayList<Student> list = new ArrayList<>();

        Student st1 = new Student("张三",20);
        Student st2 = new Student("李四",22);
        Student st3 = new Student("王五",21);


        list.add(st1);
        list.add(st2);
        list.add(st3);

        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            System.out.println(student.getName()+", "+student.getAge());
        }

    }
}
